fstats_experimental_design Module



Interfaces

public interface doe_evaluate_model

  • private function doe_evaluate_model_1(nway, beta, x, map) result(rst)

    Evaluates the model of the following form.

    Arguments

    Type IntentOptional Attributes Name
    integer(kind=int32), intent(in) :: nway

    The number of interaction levels. Currently, this algorithm supports a maximum of three-way interaction.

    real(kind=real64), intent(in), dimension(:) :: beta

    The model coefficients.

    real(kind=real64), intent(in), dimension(:,:) :: x

    The M-by-N matrix containing the M values of each of the N factors at which to evaluate the model.

    logical, intent(in), optional, target, dimension(:) :: map

    An optional array of the same size as beta that can be used to eliminate a parameter from the model (false), or keep a parameter in the model (true). If not supplied, all parameters will be assumed to be part of the model as if the array were filled with all true values.

    Return Value real(kind=real64), allocatable, dimension(:)

    The resulting M-element array.

  • private function doe_evaluate_model_2(mdl, x) result(rst)

    Evaluates the model of the following form.

    Arguments

    Type IntentOptional Attributes Name
    class(doe_model), intent(in) :: mdl

    The model to evaluate.

    real(kind=real64), intent(in), dimension(:,:) :: x

    The M-by-N matrix containing the M values of each of the N factors at which to evaluate the model.

    Return Value real(kind=real64), allocatable, dimension(:)

    The resulting M-element array.


Derived Types

type, public ::  doe_anova_table

ANOVA table for overall model fit assessment.

Components

Type Visibility Attributes Name Initial
integer(kind=int32), public :: df_model

Model degrees of freedom.

integer(kind=int32), public :: df_residual

Residual degrees of freedom.

integer(kind=int32), public :: df_total

Total degrees of freedom.

real(kind=real64), public :: f_statistic

F-statistic.

real(kind=real64), public :: ms_model

Model mean square.

real(kind=real64), public :: ms_residual

Residual mean square.

real(kind=real64), public :: p_value

P-value for the F-test.

real(kind=real64), public :: r_squared

R-squared value.

real(kind=real64), public :: ss_model

Model sum of squares.

real(kind=real64), public :: ss_residual

Residual sum of squares.

real(kind=real64), public :: ss_total

Total sum of squares.

type, public ::  doe_comparison_result

Results from comparing two models.

Components

Type Visibility Attributes Name Initial
character(len=256), public :: conclusion

Interpretation of comparison results.

integer(kind=int32), public :: df_diff

Difference in degrees of freedom.

integer(kind=int32), public :: df_full

Degrees of freedom for full model.

integer(kind=int32), public :: df_reduced

Degrees of freedom for reduced model.

real(kind=real64), public :: f_statistic

F-statistic for model comparison.

real(kind=real64), public :: p_value

P-value for the F-test.

real(kind=real64), public :: rss_full

Residual sum of squares for full model.

real(kind=real64), public :: rss_reduced

Residual sum of squares for reduced model.

logical, public :: significant_difference

True if models differ significantly (p < 0.05).

type, public ::  doe_diagnostics

Model diagnostics and goodness-of-fit metrics.

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: f_p_value

P-value for the overall F-statistic.

real(kind=real64), public :: f_statistic

Overall F-statistic for the model.

real(kind=real64), public :: mean_response

Mean of the response variable.

integer(kind=int32), public :: n_observations

Number of observations.

integer(kind=int32), public :: n_parameters

Number of model parameters (including intercept).

real(kind=real64), public :: r_squared

The coefficient of determination (R²), range [0, 1].

real(kind=real64), public :: r_squared_adjusted

The adjusted R² accounting for model complexity.

real(kind=real64), public :: residual_std_error

Residual standard error (standard deviation of residuals).

real(kind=real64), public :: rmse

Root mean square error.

type, public ::  doe_efficiency_metrics

Design efficiency metrics for evaluating design quality.

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: a_efficiency

Higher is better.

real(kind=real64), public :: d_efficiency

Range [0,1]. Higher is better (max=1 for orthogonal designs).

real(kind=real64), public :: g_efficiency

G-efficiency: 1 - (max_prediction_variance / avg_prediction_variance)

logical, public :: is_orthogonal

True if design is perfectly orthogonal.

integer(kind=int32), public :: n_factors

Number of factors.

integer(kind=int32), public :: n_parameters

Number of model parameters.

integer(kind=int32), public :: n_runs

Number of design runs.

real(kind=real64), public :: orthogonality

Orthogonality measure: if perfectly orthogonal, otherwise.

type, public ::  doe_model

A model used to represent a design of experiments result. The model is of the following form.

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=real64), public, allocatable, dimension(:) :: coefficients

The model coefficients.

logical, public, allocatable, dimension(:) :: map

An array denoting if a model coefficient should be included as part of the model (true), or neglected (false).

integer(kind=int32), public :: nway

The number of interaction levels.

type(regression_statistics), public, allocatable, dimension(:) :: stats

Statistical information for each model parameter.

type, public ::  doe_optimization_result

Results from RSM-based optimization.

Components

Type Visibility Attributes Name Initial
logical, public :: converged

Whether optimization converged.

real(kind=real64), public :: convergence_tolerance

Tolerance used for convergence.

integer(kind=int32), public :: iteration_count

Number of iterations to converge.

character(len=256), public :: method

Optimization method used.

real(kind=real64), public, allocatable, dimension(:) :: optimal_coded_factors

Optimal factor settings (in coded scale).

real(kind=real64), public, allocatable, dimension(:) :: optimal_natural_factors

Optimal factor settings (in natural scale).

real(kind=real64), public :: optimal_response

Predicted response at optimal point.

type, public ::  doe_prediction

Prediction with uncertainty quantification.

Components

Type Visibility Attributes Name Initial
real(kind=real64), public :: confidence_level

Confidence level (e.g., 0.95 for 95% CI).

real(kind=real64), public, allocatable, dimension(:) :: confidence_lower

Lower confidence interval bounds.

real(kind=real64), public, allocatable, dimension(:) :: confidence_upper

Upper confidence interval bounds.

real(kind=real64), public, allocatable, dimension(:) :: predicted_values

Predicted response values.

real(kind=real64), public, allocatable, dimension(:) :: prediction_lower

Lower prediction interval bounds.

real(kind=real64), public, allocatable, dimension(:) :: prediction_upper

Upper prediction interval bounds.

type, public ::  doe_residuals

Residual analysis data.

Components

Type Visibility Attributes Name Initial
real(kind=real64), public, allocatable, dimension(:) :: observed_values

Observed response values.

real(kind=real64), public, allocatable, dimension(:) :: predicted_values

Predicted response values.

real(kind=real64), public :: residual_mean

Mean of residuals (should be ~0).

real(kind=real64), public :: residual_std

Standard deviation of residuals.

real(kind=real64), public, allocatable, dimension(:) :: residuals

Raw residuals: y - y_predicted.

real(kind=real64), public, allocatable, dimension(:) :: standardized_residuals

Standardized residuals for outlier detection.

type, public ::  doe_rsm_model

Response Surface Model (quadratic model for RSM).

Components

Type Visibility Attributes Name Initial
type(doe_model), public :: base_model

Base fitted model.

real(kind=real64), public, allocatable, dimension(:) :: interaction_coeff

Interaction coefficients.

real(kind=real64), public :: intercept

Model intercept.

real(kind=real64), public, allocatable, dimension(:) :: linear_coeff

Linear coefficients for each factor.

integer(kind=int32), public :: n_factors

Number of factors.

real(kind=real64), public, allocatable, dimension(:) :: quadratic_coeff

Quadratic coefficients (main effects squared).

real(kind=real64), public :: response_at_center

Predicted response at design center (coded 0,0,...,0).


Functions

public function doe_compare_models(mdl1, mdl2, x, y) result(comp)

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl1
class(doe_model), intent(in) :: mdl2
real(kind=real64), intent(in), dimension(:,:) :: x
real(kind=real64), intent(in), dimension(:) :: y

Return Value type(doe_comparison_result)

public pure function doe_design_efficiency(x) result(metrics)

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:,:) :: x

Return Value type(doe_efficiency_metrics)

public function doe_fit_model(nway, x, y, map, alpha) result(rst)

Fits a Taylor series model to the provided data.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: nway

The number of interaction levels.

real(kind=real64), intent(in), dimension(:,:) :: x

The M-by-N matrix containing the M values of each of the N factors used to produce the results.

real(kind=real64), intent(in), dimension(:) :: y

An M-element array containing the results from the M experiments.

logical, intent(in), optional, target, dimension(:) :: map

An optional array of the same size as beta that can be used to eliminate a parameter from the model (false), or keep a parameter in the model (true). If not supplied, all parameters will be assumed to be part of the model as if the array were filled with all true values.

real(kind=real64), intent(in), optional :: alpha

The significance level at which to evaluate the confidence intervals. The default value is 0.05 such that a 95% confidence interval is calculated.

Return Value type(doe_model)

The resulting model.

public function doe_model_anova(mdl, x, y) result(anova)

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl
real(kind=real64), intent(in), dimension(:,:) :: x
real(kind=real64), intent(in), dimension(:) :: y

Return Value type(doe_anova_table)

public function doe_model_diagnostics(mdl, x, y) result(diag)

Computes model diagnostics and goodness-of-fit metrics.

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl

The fitted DOE model.

real(kind=real64), intent(in), dimension(:,:) :: x

The M-by-N matrix of factor values used in model fitting.

real(kind=real64), intent(in), dimension(:) :: y

The M-element array of observed responses.

Return Value type(doe_diagnostics)

The resulting diagnostics.

public pure function doe_optimize_rsm(mdl, x_low, x_high, method, tol) result(opt)

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl
real(kind=real64), intent(in), dimension(:) :: x_low
real(kind=real64), intent(in), dimension(:) :: x_high
character(len=*), intent(in), optional :: method
real(kind=real64), intent(in), optional :: tol

Return Value type(doe_optimization_result)

public function doe_predict(mdl, x, alpha) result(pred)

Computes predictions with confidence and prediction intervals.

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl

The fitted DOE model.

real(kind=real64), intent(in), dimension(:,:) :: x

The M-by-N matrix at which to evaluate the model.

real(kind=real64), intent(in), optional :: alpha

Significance level (default 0.05 for 95% CI).

Return Value type(doe_prediction)

The predictions with intervals.

public function doe_predict_enhanced(mdl, x, alpha, residual_mse) result(pred)

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl
real(kind=real64), intent(in), dimension(:,:) :: x
real(kind=real64), intent(in), optional :: alpha
real(kind=real64), intent(in), optional :: residual_mse

Return Value type(doe_prediction)

public function doe_residuals_analysis(mdl, x, y) result(resid)

Computes residual analysis data for model diagnostics.

Arguments

Type IntentOptional Attributes Name
class(doe_model), intent(in) :: mdl

The fitted DOE model.

real(kind=real64), intent(in), dimension(:,:) :: x

The M-by-N matrix of factor values.

real(kind=real64), intent(in), dimension(:) :: y

The M-element array of observed responses.

Return Value type(doe_residuals)

The residual analysis results.


Subroutines

public subroutine central_composite_design(nfactors, alpha_type, tbl)

Generates a central composite design in coded variables.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: nfactors

Number of factors.

character(len=*), intent(in), optional :: alpha_type

Type: "orthogonal" (default), "rotatable", "uniform".

real(kind=real64), intent(out) :: tbl(:,:)

Design table (coded variables in [-1, +1] range).

public pure subroutine central_composite_design_size(nfactors, alpha_type, m, n)

Computes the size of a central composite design.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: nfactors

Number of factors.

character(len=*), intent(in), optional :: alpha_type

Type of CCD: "orthogonal" (default), "rotatable", or "uniform".

integer(kind=int32), intent(out) :: m

Number of runs (rows).

integer(kind=int32), intent(out) :: n

Number of factors (columns).

public pure subroutine decode_variables(x_coded, x_low, x_high, x_natural)

Converts coded variable values (-1, +1) to natural scale.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:,:) :: x_coded

M-by-N matrix of coded values in range [-1, +1].

real(kind=real64), intent(in), dimension(:) :: x_low

N-element array of low values for each factor.

real(kind=real64), intent(in), dimension(:) :: x_high

N-element array of high values for each factor.

real(kind=real64), intent(out), dimension(:,:) :: x_natural

M-by-N matrix of natural (physical) variable values.

public pure subroutine encode_variables(x_natural, x_low, x_high, x_coded)

Converts natural variable values to coded (-1, +1) scale.

Arguments

Type IntentOptional Attributes Name
real(kind=real64), intent(in), dimension(:,:) :: x_natural

M-by-N matrix of natural (physical) variable values.

real(kind=real64), intent(in), dimension(:) :: x_low

N-element array of low values for each factor.

real(kind=real64), intent(in), dimension(:) :: x_high

N-element array of high values for each factor.

real(kind=real64), intent(out), dimension(:,:) :: x_coded

M-by-N matrix of coded values in range [-1, +1].

public subroutine fractional_factorial(nfactors, fraction, tbl)

Generates a 2-level fractional factorial design.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: nfactors

Number of factors.

integer(kind=int32), intent(in) :: fraction

Fraction level (1 for 1/2, 2 for 1/4, etc.).

integer(kind=int32), intent(out) :: tbl(:,:)

Design table (runs × factors), coded as 1 and 2.

public subroutine fractional_factorial_size(nfactors, fraction, m, n)

Computes the size of a fractional factorial design.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: nfactors

Number of factors (k).

integer(kind=int32), intent(in) :: fraction

Fraction level (p): 1 for 1/2, 2 for 1/4, 3 for 1/8, etc.

integer(kind=int32), intent(out) :: m

Number of runs (rows).

integer(kind=int32), intent(out) :: n

Number of factors (columns), same as nfactors.

public subroutine full_factorial(vars, tbl)

Computes a table with values scaled from 1 to N describing a full-factorial design.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: vars(:)

An M-element array containing the M factors to study.
Each of the M entries to the array is expected to contain the number of options for that particular factor to explore. This value must be greater than or equal to 1.

integer(kind=int32), intent(out) :: tbl(:,:)

A table where the design will be written. Use get_full_factorial_matrix_size to determine the appropriate table size.

public subroutine get_full_factorial_matrix_size(vars, m, n)

Computes the appropriate size for a full-factorial design table.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: vars(:)

An M-element array containing the M factors to study. Each of the M entries to the array is expected to contain the number of options for that particular factor to explore.
This value must be greater than or equal to 1.

integer(kind=int32), intent(out) :: m

The number of rows for the table.

integer(kind=int32), intent(out) :: n

The number of columns for the table.

public subroutine latin_hypercube_design(nfactors, nsamples, seed, tbl)

Generates a Latin hypercube design for factor space exploration.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: nfactors

Number of factors.

integer(kind=int32), intent(in) :: nsamples

Number of samples (runs).

integer(kind=int32), intent(inout), optional :: seed

Random seed for reproducibility.

real(kind=real64), intent(out) :: tbl(:,:)

Latin hypercube design (nsamples × nfactors).